// kd:
// If you ever feel the need to make a new shopkeeper, this'll hopefully help
// out with most things concerning that business.

// There's a lot of stuff possible, but you usually don't need half of it.

// To test your shopkeeper, you have to cycle to it in the shop (there's a
// button in the top left).

// With the template below, you should get a bunch of uh... diagnostic messages
// I guess. If the shopkeeper doesn't spawn, it'll just fall back to Nithor's
// commentary, but no shopkeeper.

class Gcs_Testkeeper : Gcs_Shopkeeper {
	default {
		// By default, scale is 0.5. Nithor uses 0.2666.
		
		// WHO AM I AND WHAT IS MY FAVOURITE COLOUR?
		Gcs_Shopkeeper.NameKey "Dr. Template";
		Gcs_Shopkeeper.ConsoleColor "\c[ice]";
		
		// Some visual stuff:
		Gcs_Shopkeeper.ViewDistance 80;	// How far in front
		Gcs_Shopkeeper.Zoffset -5;		// Vertical offset
		
		// This is for shopkeeper talk, like when Nithor says hi or gets
		// bored, the text changes colour as it fades in.
		Gcs_Shopkeeper.TalkStartColor Font.CR_BLACK;
		Gcs_Shopkeeper.TalkFinalColor Font.CR_DARKRED;
		
		// This will be used to look up item commentary. You'd make a language
		// file with entries like this:
		
		// <item class name>_desc_<commentary key>
		
		Gcs_Shopkeeper.CommentaryKey "nithor";
	}
	
	// This gets called when the shop wants to kill your shopkeeper, so you have
	// to put it into a state where it eventually dies. OnDestroy will then
	// either spawn the next or do nothing if the shop is closing.
	override void OnRemove () {
		ConsoleSpeak("I'mma leave.");
		Destroy();
	}
	
	// Just when the shopkeeper gets spawned. You can use this opportunity to
	// let them say hi.
	override void PostBeginPlay () {
		ConsoleSpeak("I AM A FUCKING WAFFLE.");
	}
	
	// Whenever the player tries to buy an item. You can check the result to
	// say "nah you're too poor" or "it's yours". You can also get the item
	// class from the shop, to make special cases like the EXTREME sphere.
	
	
	
	
	override void OnBuy (int result, uint shop_i, uint item_i) {
		ConsoleSpeak("You tried buying a thing! Here's more:");
		
		switch(result) {
		case Gc_Shop_Inv.EVENT_BUY_OKAY:
			ConsoleSpeak("You actually succeeded!");
			break;
		
		// I think I turned off buying worse items, so this never happens.
		case Gc_Shop_Inv.EVENT_BUY_OKAY_BUT_WORSE:
			ConsoleSpeak("It's worse, but you succeeded anyway.");
			break;
		
		case Gc_Shop_Inv.EVENT_BUY_MAXED:
			ConsoleSpeak("You got enough of this one!");
			break;
		
		case Gc_Shop_Inv.EVENT_BUY_CANT_CARRY:
			ConsoleSpeak("You cannot carry this for some other reason!");
			break;
		
		case Gc_Shop_Inv.EVENT_BUY_POOR:
			ConsoleSpeak("You cannot afford this.");
			break;
		}
	}
	
	// Whenever the player tries equipping an item. Same idea as OnBuy.
	override void OnEquip (int result, uint shop_i, uint item_i) {
		ConsoleSpeak("You tried equipping a thing, here's more:");
		
		switch(result) {
		case Gc_Shop_Inv.EVENT_EQUIP_OKAY_ON:
			ConsoleSpeak("Item is now on!");
			break;
		case Gc_Shop_Inv.EVENT_EQUIP_OKAY_OFF:
			ConsoleSpeak("Item is now off.");
			break;
		case Gc_Shop_Inv.EVENT_EQUIP_DONT_HAVE:
			ConsoleSpeak("You don't have this!");
			break;
		case Gc_Shop_Inv.EVENT_EQUIP_CANT:
			ConsoleSpeak("This cannot be equipped!");
			break;
		case Gc_Shop_Inv.EVENT_EQUIP_ALREADY:
			ConsoleSpeak("You already equipped this!");
			break;
		case Gc_Shop_Inv.EVENT_EQUIP_NOT_YET:
			ConsoleSpeak("You cannot equip this for some other reason!");
			break;
		}
	}
	
	// Whenever you click a button, like the left and right arrows on the
	// screen. I think I wanted to place one over the shopkeeper in the middle,
	// too, so one can code a special interaction or whatever.
	override void OnAction (int button) {
		ConsoleSpeak("You tried clicking a button.");
	}
	
	override void OnItemHover (int shop_index, int item_index) {
		ConsoleSpeak("You hovered the item.");
	}
	
	override void OnItemDehover (int shop_index, int item_index) {
		ConsoleSpeak("You dehovered the item.");
	}
	
	// This allows you to intervene when the user buys something. Like, if the
	// player can buy something, you can put a last check here for that item to
	// say "no, don't lol". true means "you can buy this".
	
	// In these functions marked "const", you shouldn't spawn things. It'll
	// cause a desync!
	/*override bool HookBuy (int shop_i, int item_i) const {
		return true;
	}
	
	// Same idea, but for equipping.
	override bool HookEquip (int shop_i, int item_i) const {
		return true;
	}
	
	// Same idea, but for clicking buttons.
	override bool HookButtonClick (int button) const {
		return true;
	}*/
}